package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Borrowed implements IOPer{
    @Override
    public void work(BookList bookList) {
        System.out.println("要借哪本书");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int sz = bookList.getUsersize();
        for (int i = 0; i < sz; i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)) {
                if (book.isOut()==false) {
                    book.setOut(true);
                    System.out.println("成功借书");
                    return;
                }

            }
        }
        System.out.println("没有此书");

    }
}
